package com.bms.hystrix.controller.kzkyzl;


import com.bms.hystrix.service.kzkyzl.CheckService;
import com.bms.hystrix.vo.KongZhiKeYanZhiLiangGengXiShenHe;
import com.bms.hystrix.vo.KongZhiKeYanZhiLiangGengXiYuanGong;
import com.bms.hystrix.vo.KongZhiKeYanZhiLiangGengXinByIdVo;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

// 基于feign中创建的controller进行改造，这次注入的是service
@RestController
@RequestMapping("/KeYanZhiLiangKongZhi")
@Api(value = "控制科研项目(KeYanZhiLiangKongZhi)项目管理",tags = "控制科研项目(KeYanZhiLiangKongZhi)项目管理接口API")
@ApiResponses({
        @ApiResponse(code=400,message="请求参数不完整或者错误"),
        @ApiResponse(code=404,message="找不到页面"),
        @ApiResponse(code=405,message="请求方式不正确，比如后台接收是post，但前端请求的是get"),
        @ApiResponse(code=406,message="页面地址和接口名冲突"),
        @ApiResponse(code=415,message="请求格式不正确，前端可能没有把请求头修改为json，也可能前端请求的json对象没有转换为字符串"),
        @ApiResponse(code=500,message="后台服务逻辑错误")
})
public class CheckController {
    @Resource
    private CheckService checkService;

    /*
    这里类似于ribbon，提供一个对外访问的接口地址，
    然后根据serviceFeignByCheck接口来决定调用哪一个子模块服务和哪一个接口地址
     */
//    @RequestMapping(value = "/check",method = RequestMethod.GET,
//            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    public Map check(String name) {
//        return checkService.check(name);
//    }

//    @RequestMapping(value = "/ChaXun",method = RequestMethod.GET,
//            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    public Map ChaXun(String xiangmuming,String faburen,String zhixingzhuangtai) {
//        return checkService.ChaXun(xiangmuming,faburen,zhixingzhuangtai);
//    }

//    @RequestMapping(value = "/gengXinById",method = RequestMethod.POST,
//            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    public Map gengXinById(KongZhiKeYanZhiLiangGengXinByIdVo kongZhiKeYanZhiLiangGengXinByIdVo) {
//        return checkService.gengXinById(kongZhiKeYanZhiLiangGengXinByIdVo);
//    }

//    @RequestMapping(value = "/chaXunAll",method = RequestMethod.GET,
//            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    public Map chaXunAll() {
//        return checkService.chaXunAll();
//    }
//
//    @RequestMapping(value = "/gengXinYuanGong",method = RequestMethod.POST,
//            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    public Map gengXinYuanGong(KongZhiKeYanZhiLiangGengXiYuanGong kongZhiKeYanZhiLiangGengXiYuanGong) {
//        return checkService.gengXinYuanGong(kongZhiKeYanZhiLiangGengXiYuanGong);
//    }
//
//    @RequestMapping(value = "/gengXinShenHe",method = RequestMethod.POST,
//            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    public Map gengXinShenHe(KongZhiKeYanZhiLiangGengXiShenHe kongZhiKeYanZhiLiangGengXiShenHe) {
//        return checkService.gengXinShenHe(kongZhiKeYanZhiLiangGengXiShenHe);
//    }

    /**
     * 模糊查询数据
     * @param xiangmuming,faburen,zhixingzhuangtai  模糊查询的内容
     * @return 单条数据
     */
    @RequestMapping(value = "ChaXun", method = RequestMethod.GET)
    @ApiOperation(value = "控制科研质量查询接口",notes = "控制科研质量查询接口",httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "xiangmuming",value = "项目名",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "faburen",value = "发布人",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "zhixingzhuangtai",value = "执行状态",paramType = "query",dataType = "String",required = false)
    })
    public Map<String, Object> ChaXun(String xiangmuming,String faburen,String zhixingzhuangtai) {
        return checkService.ChaXun(xiangmuming, faburen,zhixingzhuangtai);
    }

    /**
     * 通过ID更新预定项目目标数据
     *
     * @param kongZhiKeYanZhiLiangGengXinByIdVo 一个数据库对应的vo数据对象
     * @return 单条数据
     */
    @RequestMapping(value = "gengXinById", method = RequestMethod.POST)
    @ApiOperation(value = "通过主键更新预约项目目标的接口",notes = "通过主键更新预约项目目标的接口",httpMethod = "POST")
    public Map<String, Object> gengXinById(@RequestBody @ApiParam(name = "kongZhiKeYanZhiLiangGengXinByIdVo",value = "vo模型",required = false) KongZhiKeYanZhiLiangGengXinByIdVo kongZhiKeYanZhiLiangGengXinByIdVo) {
        return checkService.gengXinById(kongZhiKeYanZhiLiangGengXinByIdVo);
    }

    /**
     * 查询所有科研人员数据
     * @return 返回所有数据
     */
    @RequestMapping(value = "chaXunAll", method = RequestMethod.GET)
    @ApiOperation(value = "查询所有科研人员数据接口",notes = "查询所有科研人员数据接口",httpMethod = "GET")
    public Map<String, Object> chaXunAll() {
        return checkService.chaXunAll();
    }


    /**
     * 通过ID更新员工数据
     *
     * @param kongZhiKeYanZhiLiangGengXiYuanGong 一个数据库对应的vo数据对象
     * @return 单条数据
     */
    @RequestMapping(value = "gengXinYuanGong", method = RequestMethod.POST)
    @ApiOperation(value = "通过主键增加项目员工的接口",notes = "通过主键增加项目员工的接口",httpMethod = "POST")
    public Map<String, Object> gengXinYuanGong(@RequestBody @ApiParam(name = "KongZhiKeYanZhiLiangGengXiYuanGong",value = "vo模型",required = false) KongZhiKeYanZhiLiangGengXiYuanGong kongZhiKeYanZhiLiangGengXiYuanGong) {
        return checkService.gengXinYuanGong(kongZhiKeYanZhiLiangGengXiYuanGong);
    }

    /**
     * 通过ID更新员工数据
     *
     * @param kongZhiKeYanZhiLiangGengXiShenHe 一个数据库对应的vo数据对象
     * @return 单条数据
     */
    @RequestMapping(value = "gengXinShenHe", method = RequestMethod.POST)
    @ApiOperation(value = "通过主键审核经费接口",notes = "通过主键审核经费接口",httpMethod = "POST")
    public Map<String, Object> gengXinShenHe(@RequestBody @ApiParam(name = "KongZhiKeYanZhiLiangGengXiShenHe",value = "vo模型",required = false) KongZhiKeYanZhiLiangGengXiShenHe kongZhiKeYanZhiLiangGengXiShenHe) {
        return checkService.gengXinShenHe(kongZhiKeYanZhiLiangGengXiShenHe);
    }

}